package dao

import (
	"fmt"
	"geekbang-go-homework/module1/dao/po"
	"geekbang-go-homework/module1/errors"
)

// UserMongoDB 访问MongoDB实例
type UserMongoDB struct {
}

// Get 从MongoDB中获取数据
func (u *UserMongoDB) Get(id int) (*po.User, error) {
	if id < 100 {
		return &po.User{
			ID:       id,
			UserName: fmt.Sprintf("user %d", id),
		}, nil
	}
	return nil, errors.ErrNoRows()
}
